package com.woniuxy.joylife.manager.controller;

import com.woniuxy.joylife.manager.entity.ComplainEntity;
import com.woniuxy.joylife.manager.service.ComplainService;
import com.woniuxy.joylife.manager.utils.PageUtils;
import com.woniuxy.joylife.manager.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 意见信息
 *
 * @author renxiang
 * @email 981405195@qq.com
 * @date 2020-05-13 02:47:54
 */
@RestController
@RequestMapping("manager/complain")
public class ComplainController {
    @Autowired
    private ComplainService complainService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("manager:complain:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = complainService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{compId}")
    //@RequiresPermissions("manager:complain:info")
    public R info(@PathVariable("compId") String compId){
		ComplainEntity complain = complainService.getById(compId);

        return R.ok().put("complain", complain);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("manager:complain:save")
    public R save(@RequestBody ComplainEntity complain){
		complainService.save(complain);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("manager:complain:update")
    public R update(@RequestBody ComplainEntity complain){
		complainService.updateById(complain);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("manager:complain:delete")
    public R delete(@RequestBody String[] compIds){
		complainService.removeByIds(Arrays.asList(compIds));

        return R.ok();
    }

}
